package com.xmall.order.service.impl.other;

import com.xmall.order.define.dto.OrderItemDto;
import com.xmall.order.service.other.IAmountCalculateService;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class AmountCalculateServiceImpl implements IAmountCalculateService {

    /**
     * 计算商品总金额
     */
    @Override
    public BigDecimal calculateProductAmount(List<OrderItemDto> list) {
        return list.stream().map(OrderItemDto::getTotalAmount).reduce(BigDecimal.ZERO, (prev, next) -> prev.add(next));
    }

    /**
     * 计算优惠金额
     */
    @Override
    public BigDecimal calculateDiscountAmount() {
        return BigDecimal.ZERO;
    }

    /**
     * 计算运费金额
     */
    @Override
    public BigDecimal calculateDeliveryAmount() {
        return BigDecimal.ZERO;
    }
}
